package com.kdtech.analyse.video;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import com.kdtech.crawler.CrawlHTML;
import com.kdtech.entity.crawler.UrlMeta;
import com.kdtech.entity.data.NewsMeta;
import com.kdtech.utils.DateUtils;
import com.kdtech.utils.StringUtils;
import com.kdtech.analyse.AnalyseNews;

/**
 * 葫芦岛广播电视网
 * @author Administrator
 * abc
 */
public class HldbtvAnalyse implements AnalyseNews{
	
	public boolean isDetailPage(String url) {
		boolean bRet = false;
		String[] regex = {
				"http://www.hldbtv.com/ProgramsData/Item_[0-9]{4,5}.aspx"
				};
		for (int i = 0; i < regex.length; i++) {
			if (url.matches(regex[i])) {
				return true;
			}
		}
		return bRet;
	}

	
	public NewsMeta parserHtml(UrlMeta urlMeta) {
		NewsMeta video = new NewsMeta();
		if (urlMeta.getHtml() == null) {
		}
		String htmltxt = urlMeta.getHtml();
		String url = urlMeta.getUrl();
		if(!isDetailPage(url)){
		}
		video.setUrl(url);
		String title = null;
		String desc = null;
		Long date = null;
		String dateStr = null;
		Document doc = Jsoup.parse(htmltxt);
		title = doc.select("h1").text();

		    desc = doc.select("div#articleContnet").text();
			dateStr =doc.select("div.ele_inner > div.p15.mt10 > p.tc.c_666.mt10").text();
			date = DateUtils.matchDate(dateStr);
			if(date==null){
				date=DateUtils.matchDate(doc.select("div.article_content div.article_info").text());
			}
			video.setTitle(StringUtils.trimSpace(title));
			video.setContent(desc);
			video.setDate(date);
			return video;
	}
	

	
	public NewsMeta Update(NewsMeta meta) {
		return null;
	}
	
}
